<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			for (var i = 0; i < 5; i++) {
				console.log(i);

				(function (i){
					setTimeout(function() {
						console.log(i);
					}, 1000);
				}(i));

			}
		</script>
	</body>
</html>
